﻿function submit_login() {
    var admin_uname = $("#LoginCode").val();
    var admin_psw = $("#LoginPwd").val();
    if (admin_uname == "") {
        alert("请输入您用户账号！");
        $("#LoginCode").focus();
        return false
    }
    if (admin_psw == "") {
        alert("请输入您的登录密码！");
        $("#LoginPwd").focus();
        return false
    }
    $.ajax({
        type: "get",
        url: "../../Service/PublicHandler.ashx?action=UserLogin&paramName=" + escape(admin_uname) + "&paramPwd=" + admin_psw,
        cache: false,
        success: function (reg) {
            var arr = reg.split('|');
            var returnval = arr[0];
            var tip = arr[1];

            if (returnval == "EXP") {
                top.location.href = "#";
                return false;
            }
            if (returnval == "1") {
                $("#msg_tip").text(tip);
                document.getElementById("LoginCode").value = "";
                document.getElementById("LoginPwd").value = "";
                document.getElementById("LoginCode").focus();
                return false;
            }
            if (returnval == "3") {
                $("#msg_tip").text(tip);
                document.getElementById("LoginCode").value = "";
                document.getElementById("LoginPwd").value = "";
                document.getElementById("LoginCode").focus();
                return false;
            }
            else if (returnval == "9") {
                $("#msg_tip").text(tip);
                document.getElementById("LoginCode").select();
                document.getElementById("LoginPwd").value = "";
                document.getElementById("LoginPwd").focus();
                return false;
            }
            else if (returnval == "14") {
                $("#msg_tip").text(tip);
                document.getElementById("LoginCode").select();
                document.getElementById("LoginCode").value = "";
                document.getElementById("LoginPwd").value = "";
                document.getElementById("LoginCode").focus();
                return false;
            }
            else if (returnval == "20" || returnval == "30") {
                $("#msg_tip").text(tip);
                document.getElementById("LoginCode").value = "";
                document.getElementById("LoginPwd").value = "";
                document.getElementById("LoginCode").focus();
                return false;
            }
            else if (returnval == "10") {
                $("#msg_tip").text("");
                window.location.href = "index.aspx";
            }
        },
        error: function () {
            $("#msg_tip").text("参数出错，请与管理员联系!");
            document.getElementById("LoginCode").value = "";
            document.getElementById("LoginPwd").value = "";
            document.getElementById("LoginCode").focus();
        }
    });
}

function doReset() {
    $("#LoginCode").focus();
}

function forgetPwd() {
    window.showModalDialog('CommForm/ForgetPwdForm.aspx', window, 'dialogWidth=300px;dialogHeight=198px;status=no');
}